/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pt.ipleiria.plp;

//#ifdef polish.api.locationapi
import javax.microedition.location.Coordinates;
import javax.microedition.location.Criteria;
import javax.microedition.location.Location;
import javax.microedition.location.LocationException;
import javax.microedition.location.LocationProvider;
//#endif

/**
 *
 * @author Filipe
 */
public class GPS {

    public static final int TIME_OUT = 60;
    //#ifdef polish.api.locationapi
    LocationProvider lp;
    //#endif

    public GPS() throws LocationException {
        Criteria cr = new Criteria();
        cr.setHorizontalAccuracy(500);

        lp = LocationProvider.getInstance(cr);

    }

    public Coordinates getLocation() throws InterruptedException, LocationException {
        Location l = lp.getLocation(TIME_OUT);
        return l.getQualifiedCoordinates();

    }
}
